<template>
    <div class="box">
      <div class="cg">
        <u-icon name="checkbox-mark" color="#fff" size="46"></u-icon>
      </div> 
      <p class="title">购买成功</p>
      <p class="text">请在 诸信接单 内查看剩余条数~</p>
      <div class="anniu">
        <wx-open-launch-weapp id="launch-btn" appid="wx066f87c1fd98e952" username="gh_0048934ca6a7" path='pages/index/index'>
          <script type="text/wxtag-template">
          <style scoped>.btn {
            display: block;
            width: 100%;
            height: 96rpx;
            line-height: 96rpx;
            border-radius: 100rpx;
            background: #23ac39;
            font-size: 32rpx;
            text-align: center;
            font-weight: 500;
            color: #fff;
            border: none;}
          </style>
          <button class="btn">返回小程序</button>
          </script>
        </wx-open-launch-weapp>
      </div>
    </div>
  </template>
  
  <script>
  import api from '@/api';
  import wx from "@/utils/jweixin-1.6.0.js"
  export default {
    data(){
      return{
        
      }
    },
    methods:{
      back(){
        uni.navigateBack({//返回
          delta: 1
        })
      },
    },
    onLoad(){
    },
    async onShow() {
      let url = location.href
      await api.user.getJsapiSignature(url).then(res=>{
        if (res.code == 200) {
          wx.config({
            debug: false,
            appId: res.data.appId, // 公众号
            timestamp: res.data.timestamp, // 
            nonceStr: res.data.nonceStr, // 必填，生成签名的随机串
            signature: res.data.signature, // 必填，签名
            jsApiList: [
            "onMenuShareTimeline",
            "onMenuShareAppMessage",
            "checkJsApi",
            "scanQRCode"
            ],
            openTagList: ["wx-open-launch-weapp"],
          });
          wx.ready(function (res) {
            var btn = document.getElementById("launch-btn");
            btn.addEventListener("ready", function (e) {});
            btn.addEventListener("launch", function (e) {});
            btn.addEventListener("error", function (e) {
            alert('error');
            alert(JSON.stringify(e));
            });
            console.log('成功', res)
          });
          wx.error(function (res) {
            console.log('失败', res);
          })
        }
      })
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .box{
    min-height: 100vh;
    .cg{
      width: 136rpx;
      height: 136rpx;
      background: #23ac39;
      border-radius: 50%;
      margin:200rpx auto 40rpx auto;
      color:#fff;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .title{
      font-size:36rpx;
      color:#333;
      text-align: center;
      font-weight: 600;
    }
    .text{
      width: 80%;
      margin:0 auto;
      color:#666666;
      font-size:28rpx;
      text-align: center;
      margin-top:20rpx;
      line-height: 42rpx;
    } 
    .anniu{
      display: flex;
      justify-content: center;
      margin:200rpx 32rpx 0 32rpx;
      p{
        width: 40%;
        height: 80rpx;
        line-height: 80rpx;
        color: #F2DBA8;
        background-color: #2F2D2D;
        border-radius: 10rpx;
        text-align: center;
        font-size: 30rpx;
        &:first-child{
          background-color: #fff;
          border: 2rpx solid #F2DBA8;
          color: #F2DBA8;
          box-sizing: border-box;
          // margin-right: 22rpx;
          // width: 70%;
        }
      }
    }
    
  }
  #launch-btn{
    width: 46%;
    display: block;
  }
  </style>